package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.Role;
import com.itheima.pojo.User;
import com.itheima.service.RoleService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RoleController {

    @Reference
    private RoleService roleService;

    // /role/findPage  分页查询
    @RequestMapping("/role/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        return roleService.findPage(queryPageBean);
    }

     // /role/getPermission 查询所有的 权限信息
    @RequestMapping("/role/getPermission")
    public Result getAllPermission(){
        return roleService.getAllPermission();
    }

    // /role/getMenu 查询所有的菜单信息
    @RequestMapping("/role/getMenu")
    public Result getMenu(){
        return roleService.getAllMenu();
    }

    // /role/add  新增数据
    @RequestMapping("/role/add")
    public Result add(Integer []checkitemIds,Integer []checkitemId1s,@RequestBody Role role){
        return roleService.add(checkitemIds,checkitemId1s,role);
    }

    // /role/findById 查询角色信息
    @RequestMapping("/role/findById")
    public Result findById(Integer id){
        return roleService.findById(id);
    }

    // /role/findRoleIdsByPermissionId
    @RequestMapping("/role/findRoleIdsByPermissionId")
    public Result findRoleIdsByPermissionIds(Integer id){
        return roleService.permissionIds(id);
    }

    // /role/findRoleByMenuId   id
    @RequestMapping("/role/findRoleByMenuId")
    public Result findRoleByMenuId(Integer id){
        return roleService.findRoleByMenuId(id);
    }
    // /role/edit

    @RequestMapping("/role/edit")
    public Result edit(Integer []checkitemIds,Integer []checkitemId1s,@RequestBody Role role){
        return roleService.edit(checkitemIds,checkitemId1s,role);
    }

    // /role/delete 删除角色
    @RequestMapping("/role/delete")
    public Result delete(Integer id){
        return roleService.delete(id);
    }
}
